package com.itheima.dao;

import com.itheima.bean.Student;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class AddStudent {
    public boolean addStudent(Student stu,String realPath){
        BufferedWriter bw= null;
        try {
            bw = new BufferedWriter(new FileWriter(realPath,true));
            bw.write(stu.getUsername()+","+stu.getAge()+","+stu.getScore());
            bw.newLine();

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
           if(bw!=null){
               try {
                   bw.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }
           }
        }
        return true;
    }
}
